<form method ="POST" >
    <table>
        
           <tr> <td>Min:</td><td>  <input type ="text" name ="Min"></td></tr>
            <tr><td>Max:</td><td> <input type ="text" name ="Max"></td></tr>
            <tr><td>Key word:</td><td><input type="text" name ="Keyword"></td></tr>

        </tr></br>
        <tr><td> <input type ="submit" name ="submit" value ="search"></td></tr>

    </table>
</form>

<?php
require_once 'model/db.php';
$query = "SELECT * FROM pages";
$pages = getPages($query);
?>
<?php if (isset($_POST['submit'])): ?>
    <?php
    $min = (int) $_POST['Min'];
    $max = (int) $_POST['Max'];
    $keyword=$_POST['Keyword'];
    ?>

    <table border ="1">
        <tr>
            <th>Pid</th>
            <th>Picture</th>
            <th>ID</th>
            <th>Name</th>
            <th>Username</th>
            <th>Phone</th>
            <th>Like</th>
            <th>Link</th>
            <th>talking_about_count</th>
            <th>category</th>
        </tr>

        <?php foreach ($pages as $page): ?>
            <?php
            if ( (empty($keyword))&&(int)$page['likes'] >= ((int) $_POST['Min']) &&
                    (int)$page['likes'] <= ((int) $_POST['Max'])):
                ?>
                <tr>

                    <td><?php echo $page['pid'] ?></td>
                    <td><img src ="<?php echo $page['picture'] ?>"> </td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td>
                    <td><?php echo $page['link'] ?></td>
                    <td><?php echo $page['talking_about_count'] ?></td>
                    <td><?php echo $page['category'] ?></td>

                </tr>
                <?php elseif 
                     (strstr($page['name'] ,$keyword) &&(int)$page['likes'] >= ((int) $_POST['Min']) &&
                    (int)$page['likes'] <= ((int) $_POST['Max'])):?>
                <tr>

                    <td><?php echo $page['pid'] ?></td>
                    <td><img src ="<?php echo $page['picture'] ?>"> </td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td>
                    <td><?php echo $page['link'] ?></td>
                    <td><?php echo $page['talking_about_count'] ?></td>
                    <td><?php echo $page['category'] ?></td>
            <?php endif; ?>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

Company: <select>
    <option>YouNet</option>
    <option>Offerpop</option>
    <option>Woobox</option>
    <option>Northsocial</option>
    <option>SocialAppsHq</option>
    <option>Fanzila</option>
    <option>Eazycontest</option>
    <option>Shortstackapp</option>
    <option>Unknow</option>
    <option>Zibaba</option>
</select>


